package org.dreamwork.jasmine2.web.html;

import org.dreamwork.jasmine2.web.controls.WebContainer;
import org.dreamwork.jasmine2.events.EventException;

import java.io.PrintWriter;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: seth
 * Date: 2009-7-27
 * Time: 18:37:26
 */
public class TableCell extends WebContainer {
    public TableCell () {
        this (false);
    }

    public TableCell (boolean isHeader) {
        this.htmlTagName = isHeader ? "th" : "td";
        viewStateEnabled = false;
    }

    @Override
    public void render (PrintWriter writer) throws IOException, EventException {
        if (childControls.isEmpty ()) {
//            writer.printf ("<td>%s</td>%n", text);
            super.beginTag (writer);
            writer.write (text.toString ());
            super.endTag (writer);
        } else
            super.render (writer);
    }
}